package com.gkzf.ai.module.crm.util.assembly;

import com.alibaba.fastjson.JSONObject;
import com.gkzf.ai.module.crm.controller.admin.creditReport.vo.creditreportdetails.CreditReportDetailsSaveReqVO;
import com.gkzf.ai.module.crm.dal.dataobject.creditReport.CreditReportBasicDO;

import java.util.Map;

public class AssembleBasicInfo {

    public static final String HEADER = "报告头";

    public static final String BASIC_INFO = "个人基本信息";

    public static final String IDENTITY_INFORMATION = "身份信息";

    public static final String REPORT_TIME = "报告时间";

//    public static final String NAME = "被查询者姓名";

    public static final String ID_NUMBER_TYPE = "被查询者证件类型";

    public static final String ID_NUMBER = "被查询者证件号码";

    public static final String GENDER = "性别";

    public static final String MARRIAGE_STATUS = "婚姻状况";

    public static final String EDUCATION = "学历";



    public void assemblyBasicInfo(Map<String, Object> param, CreditReportBasicDO creditReportBasicDO, CreditReportDetailsSaveReqVO detailsDO) {
        if (param.containsKey(HEADER)){
            JSONObject reportHeader = (JSONObject)param.get(HEADER);
            creditReportBasicDO.setIdNumber(AssembleUtils.getStringValue(reportHeader,ID_NUMBER));
            creditReportBasicDO.setDocumentType(AssembleUtils.getStringValue(reportHeader,ID_NUMBER_TYPE));
//            creditReportBasicDO.setName(AssembleUtils.getStringValue(reportHeader,NAME));
            detailsDO.setReportTime(AssembleUtils.getStringValue(reportHeader,REPORT_TIME));
        }
        if (param.containsKey(BASIC_INFO)){
            JSONObject basicInfo = (JSONObject)param.get(BASIC_INFO);
           if (basicInfo.containsKey(IDENTITY_INFORMATION)){
               JSONObject identityInformation = (JSONObject)basicInfo.get(IDENTITY_INFORMATION);
               creditReportBasicDO.setGender(AssembleUtils.getStringValue(identityInformation,GENDER));
               creditReportBasicDO.setMarriageStatus(AssembleUtils.getStringValue(identityInformation,MARRIAGE_STATUS));
               creditReportBasicDO.setEducation(AssembleUtils.getStringValue(identityInformation,EDUCATION));
           }
        }
    }

}
